package Level_two;

import java.util.Scanner;

public class Four {
    public static void main(String[] args) {
        //环录入某学生的 5 门课程的成绩并计算平均分。如果某分数录入为负，则停止录入并
        //提示录入错误。
        Scanner scanner = new Scanner(System.in);
        int[] scores = new int[5];
        int sum = 0;
        for (int i = 0; i <scores.length ; i++) {
            System.out.println("请输入第"+(1+i)+"门课程的成绩");
            int score = scanner.nextInt();
            if(score<0){
                System.out.println("录入错误");
                break;
            }else {
                scores[i] = score;
                sum+= scores[i];
            }
        }
        System.out.println("平均分为："+sum/scores.length);

    }
}

